package com.gobang.service;

import com.gobang.domain.dto.SurrenderRequestDTO;
import com.gobang.domain.vo.SurrenderResponseVO;

/**
 * 游戏房间服务接口（预留给游戏核心模块实现）
 * 提供游戏房间的创建和管理功能
 *
 * @author gobang-team
 * @since 1.0.0
 */
public interface GameRoomService {
    
    /**
     * 创建游戏房间
     * 匹配成功后调用此接口创建游戏房间
     *
     * @param blackPlayerId 黑方玩家ID
     * @param whitePlayerId 白方玩家ID
     * @return 游戏房间ID
     */
    String createGameRoom(Long blackPlayerId, Long whitePlayerId);
    
//    /**
//     * 取消游戏房间
//     * 玩家离线或其他异常情况取消房间
//     *
//     * @param roomId 房间ID
//     * @param reason 取消原因
//     */
//    void cancelGameRoom(String roomId, String reason);

    /**
     * 创建游戏房间（原方法，兼容性保留）
     *
     * @param blackPlayerId 黑方玩家ID
     * @param whitePlayerId 白方玩家ID
     * @return 房间创建结果
     */
    RoomCreationResult createRoom(Long blackPlayerId, Long whitePlayerId);

    /**
     * 处理认输请求
     *
     * @param request 认输请求
     * @return 认输响应
     */
    SurrenderResponseVO surrender(SurrenderRequestDTO request);


    /**
     * 房间创建结果
     */
    class RoomCreationResult {
        private boolean success;
        private String roomId;
        private String errorMessage;
        
        public RoomCreationResult() {}
        
        public RoomCreationResult(boolean success, String roomId, String errorMessage) {
            this.success = success;
            this.roomId = roomId;
            this.errorMessage = errorMessage;
        }
        
        /**
         * 创建成功结果
         */
        public static RoomCreationResult success(String roomId) {
            return new RoomCreationResult(true, roomId, null);
        }
        
        /**
         * 创建失败结果
         */
        public static RoomCreationResult failure(String errorMessage) {
            return new RoomCreationResult(false, null, errorMessage);
        }
        
        // Getters and Setters
        public boolean isSuccess() {
            return success;
        }
        
        public void setSuccess(boolean success) {
            this.success = success;
        }
        
        public String getRoomId() {
            return roomId;
        }
        
        public void setRoomId(String roomId) {
            this.roomId = roomId;
        }
        
        public String getErrorMessage() {
            return errorMessage;
        }
        
        public void setErrorMessage(String errorMessage) {
            this.errorMessage = errorMessage;
        }
        
        @Override
        public String toString() {
            return String.format("RoomCreationResult{success=%s, roomId='%s', errorMessage='%s'}", 
                    success, roomId, errorMessage);
        }
    }
} 